<html>
<head><meta charset="utf-8"><title>misc_question · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/misc_question.html">misc_question</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="133171822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/misc_question/near/133171822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> csmoe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/misc_question.html#133171822">(Sep 01 2018 at 10:09)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <br>
the lint </p>
<div class="codehilite"><pre><span></span><span class="n">data</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">cloned</span><span class="p">()</span><span class="w"></span>
<span class="o">^^^^</span><span class="w"> </span><span class="n">data</span><span class="w"> </span><span class="n">is</span><span class="w"> </span><span class="n">borrowed</span><span class="w"> </span><span class="n">here</span><span class="w"></span>
</pre></div>


<p>in your new diag issue <a href="https://github.com/rust-lang/rust/issues/53882" target="_blank" title="https://github.com/rust-lang/rust/issues/53882">https://github.com/rust-lang/rust/issues/53882</a> reminds me of <a href="https://github.com/rust-lang/rust/issues/25507#issuecomment-262564469" target="_blank" title="https://github.com/rust-lang/rust/issues/25507#issuecomment-262564469">https://github.com/rust-lang/rust/issues/25507#issuecomment-262564469</a></p>
<div class="codehilite"><pre><span></span>error[E0507]: cannot move out of borrowed content
 --&gt; &lt;anon&gt;:9:26
  |
9 |         println!(&quot;{:?}&quot;, y.field.unwrap_or(X));
  |                          ^ cannot move out of borrowed content
</pre></div>


<p>can we add the info like <code>Mover/Borrower</code> into diag like</p>
<div class="codehilite"><pre><span></span>data.iter().cloned()
^^^^ data is borrowed by `iter(...)`here
</pre></div>


<p>and </p>
<div class="codehilite"><pre><span></span><span class="n">error</span><span class="p">[</span><span class="n">E0507</span><span class="p">]</span>: <span class="nc">cannot</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="n">out</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="n">borrowed</span><span class="w"> </span><span class="n">content</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="o">&lt;</span><span class="n">anon</span><span class="o">&gt;</span>:<span class="mi">9</span>:<span class="mi">26</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">         </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;{:?}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="p">.</span><span class="n">field</span><span class="p">.</span><span class="n">unwrap_or</span><span class="p">(</span><span class="n">X</span><span class="p">));</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">                          </span><span class="o">^</span><span class="w"> </span><span class="n">cannot</span><span class="w"> </span><span class="k">move</span><span class="w"> </span><span class="n">out</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="n">borrowed</span><span class="w"> </span><span class="n">content</span><span class="p">,</span><span class="w"> </span><span class="n">moved</span><span class="w"> </span><span class="n">by</span><span class="w"> </span><span class="n">unwrap_or</span><span class="p">(...)</span><span class="w"></span>
</pre></div>


<p>it'll be more friendly for users to locate them.</p>



<a name="133174634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/misc_question/near/133174634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/misc_question.html#133174634">(Sep 01 2018 at 11:41)</a>:</h4>
<p>perhaps, yes. I do think there are a few things in our semantics that can be non-obvious:</p>
<ul>
<li>the <code>self</code> type of methods you invoke (as you point out here)</li>
<li>where temporaries are created, often connected with the first</li>
</ul>
<p>e.g., <code>Foo { }.iter()</code> makes a temporary, but this is not obvious</p>



<a name="133178899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/misc_question/near/133178899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/misc_question.html#133178899">(Sep 01 2018 at 14:02)</a>:</h4>
<p>(this is what I mean by "we should define a model in terms of Rust rvalues/lvalues, because this is already what a Rust user must understand" - this is all to do with lvalues)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>